package com.example.spareparts.repository;

import java.util.List;
import org.apache.ibatis.annotations.*;
import com.example.spareparts.entity.OutBoundRecords;


@Mapper
public interface OutBoundRecordsRepository {
    @Select("SELECT * FROM OutBoundRecords")
    List<OutBoundRecords> findAllOutBoundRecords();
    @Insert("INSERT INTO OutBoundRecords (spare_part_id, quantity, batch_number, date,user_id) VALUES ( #{sparepartid}, #{quantity}, #{batchNumber}, #{date},#{userid})")
    @Options(useGeneratedKeys = true, keyProperty = "outboundid")
    void insertOutBoundRecord(OutBoundRecords outBoundRecord);
    @Update("UPDATE OutBoundRecords SET outbound_id= #{outboundid}, spare_part_id= #{sparepartid}, quantity= #{quantity}, batch_number= #{batchNumber}, date= #{date} ,user_id=#{userid} WHERE outbound_id= #{outboundid}")
    void updateOutBoundRecord(OutBoundRecords outBoundRecord);
    @Delete("DELETE FROM OutBoundRecords WHERE outbound_id= #{outboundid}")
    void deleteOutBoundRecord(Long outboundid);
    @Select("SELECT * FROM OutBoundRecords WHERE outbound_id= #{outboundid}")
    OutBoundRecords findOutBoundRecordById(Long outboundid);
    @Select("SELECT * FROM OutBoundRecords WHERE spare_part_id= #{sparepartid}")
    List<OutBoundRecords> findOutBoundRecordBySparePartId(Long sparepartid);
    @Select("SELECT * FROM OutBoundRecords WHERE batch_number= #{batchNumber}")
    OutBoundRecords findOutBoundRecordByBatchNumber(String batchNumber);


}
